Learning Objectives

After completing this lesson, you’ll be able to:

Resources

View Source Schema

Jennifer continues working on her workspace in FME Workbench (2023.0 or later). This workspace creates an Esri geodatabase from a PostGIS layer. Jennifer would like her geodatabase to have a different schema than her source PostGIS data. She’d like to make the following changes:

Note

Manipulating schema (the formal definition of a dataset’s structure) is a key process in FME. When creating an FME workspace that modifies schema, there are generally two steps:

  1. Edit the schema: define what schema you want on the written data. In FME, this is done by changing the feature type parameters to reflect what you want, e.g. changing attribute or feature type names.
  2. Map the schema: define the relationship between the source schema (what you have) and the destination schema (what you want). In FME this is accomplished by using transformers to define how the old and new schema are related.

We’ll cover these two steps in this lesson and the next.

Generate Workspace has duplicated the reader schema on the writer schema in Jennifer’s workspace. Now she has to edit the schema to get the results she wants. The first step is to view the writer schema. She does that by double-clicking on the public_BusinessOwners_point feature type to open its dialog.

double-clicking on the public_BusinessOwners_point feature type to open its dialog

The writer Feature Type dialog contains all of the data’s schema information:

Viewing writer feature type schema

Note

You can view your reader feature types' schema the same way, by double-clicking a reader feature type. Note, however, that the schema cannot be modified on a reader feature type. If you wish to modify your data in-place, you'll have to add a writer feature type for the table or layer you'd like to modify.

Rename Output

Jennifer wants to rename the feature types to “BusinessOwners” and “BusinessOwners_incomplete” to distinguish features with and without geometry. She renames Feature Class or Table Name to “BusinessOwners.”

Renamed writer feature type

After changing the text, she clicks OK.

The name of the feature type is updated on the canvas.

Then she runs the workspace.

Renamed writer feature type on the canvas

Jennifer can see some of her data is missing geometry. She can tell because the GeometryFilter has results coming out of the Null port, which means that those features are neither points, lines, or polygons.

Null geometry is filtered

She wants to route the features missing geometry to their own feature class so the Quality Assurance team can fix them. Therefore, she renames the public_BusinessOwners_geom feature type to “BusinessOwners_incomplete.”

Renamed writer feature type - incomplete

When the geodatabase is written, its feature classes will have these names.

Note

In some cases, the name of a feature type will be the same name as the file created. In other cases, such as with files with multiple tables or layers, the feature type will indicate the name of the table or layer, not the file. The first parameter in all writer feature type dialogs indicates what will be created, e.g., Feature Class or Table Name for geodatabases or Sheet Name for Excel. You can set the output file or folder name in the first parameter under the writer in the Navigator.

Remove Empty Writer Feature Types

Jennifer looks at the feature counts along the connection lines coming out of the GeometryFilter. She notices no features are coming out of the LineAreaSurfaceCollection, or <Unfiltered> ports. That means there are only point and null geometries in the source data. Therefore, handling features from the Line, Area, and Surface output ports is unnecessary, as FME won’t create empty feature classes. Since nothing is being written to these feature types, she deletes the public_BusinessOwners_line and public_BusinessOwners_polygon feature types by right-clicking them and selecting Delete. Now her workspace looks like this:

Removed empty feature types

Edit Writer Feature Type Attributes

Now that Jennifer has edited the feature type names, she would also like to change the attributes. She double-clicks the BusinessOwners feature type to open the dialog. She clicks the User Attributes tab to view the attributes she wants to edit.

User Attributes tab

The table listing them can be edited. She can rename them, change their type, reorder them, or add a new attribute. She renames “first” to “first_name” by typing in the Name cell of the table.

Editing attribute name

She also changes the order of the attributes, clicking on a row to select it and then using the up and down triangle buttons at the bottom of the table to change their order. She uses the Move Down button to move “first_name” down one spot so it comes after “last_name."

Changing attribute order

Jennifer no longer wants the latitude and longitude attributes written to her feature class, so she deletes those attributes from the User Attributes tab of the writer feature type dialog. She selects their rows and clicks the Remove Row button.

Removing attributes

She clicks OK to exit the dialog and apply the changes.

View Data with Edited Schema

Jennifer wants to preview her data with the edited schema. She clicks Run, and once the workspace is finished, she clicks her BusinessOwners feature type once to select it and then clicks View Written Data.

View Written Data button

The data appears in Visual Preview. She can see in Table View that the schema has been edited, but some data is missing. For example, “last_name” is in the correct position, but “first_name” doesn’t have any values.

Table View with edited attributes

To provide the correct values to the written data, Jennifer has to map her schema, connecting the source and destination schema.

Exercise

Make sure you have followed along with Jennifer’s steps.